-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add description to inspections. #281
Conversation
I like it! |
… and matching inspections.
Is there any way to cooperate with you on this one? I find it hard to guess where you are on this one - e.g. is there some range of inspections we could take care of (by adding texts)? |
Thanks for asking, @mccartney - I think this is finished now. Here's a brief summary:
|
Since #298 is now addressed, I'll add 2.13.0 back to the build matrix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some minor adjustments to the explanations.
text = "Missing final modifier on case class", | ||
defaultLevel = Levels.Info, | ||
description = "Checks for case classes without a final modifier.", | ||
explanation = "Using case classes without final modifier can lead to surprising breakage." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's very vague. I guess we can improve it later (in a separate PR)
src/main/scala/com/sksamuel/scapegoat/inspections/LonelySealedTrait.scala
Outdated
Show resolved
Hide resolved
text = "Variable shadowing", | ||
defaultLevel = Levels.Warning, | ||
description = "Checks for multiple uses of the variable name in nested scopes.", | ||
explanation = "Variable shadowing is very useful, but can easily lead to nasty bugs in your code. Shadowed variables can be potentially confusing to other maintainers when the same name is adopted to have a new meaning in a nested scope." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is surprising:
Variable shadowing is very useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obviously this is quite subjective like a lot of other inspections. Some languages disallow variable shadowing, some allow it in some form. I personally find it useful in small and isolated scopes where otherwise I would have to make up an arbitrary name because another identifier in the scope is already using it.
src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeEqualsZero.scala
Outdated
Show resolved
Hide resolved
text = "Avoid Traversable.size == 0", | ||
defaultLevel = Levels.Warning, | ||
description = "Checks for use of Traversable.size.", | ||
explanation = "Traversable.size can be slow for some data structure, prefer Traversable.isEmpty, which is O(1)." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explanation = "Traversable.size can be slow for some data structure, prefer Traversable.isEmpty, which is O(1)." | |
explanation = "Traversable.size can be slow for some data structure, prefer .isEmpty, which is O(1)." |
src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZero.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/sksamuel/scapegoat/inspections/collections/JavaConversionsUse.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/sksamuel/scapegoat/inspections/collections/NegationIsEmpty.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/sksamuel/scapegoat/inspections/collections/NegationNonEmpty.scala
Outdated
Show resolved
Hide resolved
…AvoidSizeEqualsZero.scala
…AvoidSizeNotEqualsZero.scala
…NegationNonEmpty.scala
…JavaConversionsUse.scala
…NegationIsEmpty.scala
Thanks, @mccartney for fixing all the typos. |
@sksamuel @mccartney I've started adding descriptions to inspections, but I wanted to check with you first if you're happy with this approach before I do this for all of the inspections. I've opened this draft with just few inspections updated as an example.
Here are the key changes:
I've added a
description
to theInspection
class and made theexplanation
non-optional - I think every inspection should have it. I'm also planning to remove code snippets from all the inspections and just use the description to create each warning (maybe except for some cases where the message can be more specific, e.g. theCollectionNamingConfusion
).It might take a while to apply those changes across all of the inspections, so I wanted to make sure you're both happy with this approach before I invest the time into this PR.
Relates to #219.